n = 3

function solution(n) {
    // PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
    // write code here
    let result = []
    let i = 1
    let m = n
    while (m >= i) {
        result.push(m)
        if (m === i) {
            m = n
            i++
        } else {
            m--
        }
    }
    return result
}
console.log(solution(n));
